<html>
<head>
<script language="javascript">
location.replace("../../adminhome.php")

</script>

</head>
<body>
<?php
if(($_FILES["file"]["size"])>0)
{ 
	unlink("silver1.jpg");	

	$img="img/";
	$img.=$_FILES["file"]["name"];
	$img2=$_FILES["file"]["name"];

	if (((1==1)
		/*|| ($_FILES["file"]["type"] == "image/gif")
		|| ($_FILES["file"]["type"] == "image/pjpeg")*/)
		)
	{
		if ($_FILES["file"]["error"] > 0)
		{
			echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
		}
		else
		{
			echo "Upload: " . $_FILES["file"]["name"] . "<br />";
			echo "Type: " . $_FILES["file"]["type"] . "<br />";
			echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
			echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

			if (file_exists("img/" . $_FILES["file"]["name"]))
			{
				
				/*     echo $_FILES["file"]["name"] . " already exists. ";
			*/      }
			else
			{
				move_uploaded_file($_FILES["file"]["tmp_name"],
					"img/" . $_FILES["file"]["name"]);
				echo "Stored in: " . "img/" . $_FILES["file"]["name"];
			}
		}
	}
	else
	{
		echo "Invalid file";
	}
}
?> 




<?php
if(($_FILES["file"]["size"])>0)
{
	$new=$img2;
	include('../include.php');
	$image = new SimpleImage();
	$image->load($img);
	$image->resize(217,82);
	$image->save($new);
	rename($new,"silver1.jpg");
	unlink($img);

	$name=$_FILES["file"]["name"];
	$con = mysql_connect("localhost","appma" ,"database");
	if (!$con)
	{
		die('Could not connect: ' . mysql_error());
	}
	mysql_select_db("162_appma", $con);
	$query=	"UPDATE sponsor SET  
link = '$_POST[url]',
FilePath = '$name'
 WHERE 
sponsor = 'silver1'
";
	$update = mysql_query($query);
	if (!$update)
	{
		echo "<br>not done !";
	}
	mysql_close($con);
}
?>
</body>
</html>




